<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1, maximum-scale=1, user-scalable=no">
   
    <title>Document</title>
    <link rel="manifest" href="/manifest.json">
    <link rel="stylesheet" href="main.css">


    <meta name="theme-color" content="#5eace0"/>

    <!-- 针对safari（iOS）的添加到桌面功能进行相关设置 -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="default">
    <meta name="apple-mobile-web-app-title" content="图书搜索">
    <link rel="apple-touch-icon" href="images/book-256.png">

    <!-- IE的设置 -->
    <meta name="application-name" content="图书搜索" />
    <meta name="msapplication-TileColor" content="#222">
    <meta name="msapplication-square70x70logo" content="images/book-72.png" />
    <meta name="msapplication-square150x150logo" content="images/book-144.png" />
    <meta name="msapplication-square310x310logo" content="images/book-256.png" />
</head>
<style>
    .page{
        width: 200px;
        height: 200px;
      
    }
</style>
<body >
    <div class="page"></div>
</body>
<script src="main.js"></script>
<script>
        // 实时时获取最新版本
    

//    async function getVer(){
//         let verData =  await fetch('http://localhost/version.json?v='+new Date()).then((res)=>{
//         if(res.status == 200){
//             return res.json();
//         }else {
//             return {}
//         }
//         }).then(data => { return data;}); 
//         window.version = verData.version;
//     }
//     getVer();

    if ('serviceWorker' in navigator) {
        window.addEventListener('load', function() {
            navigator.serviceWorker.register('/sw.js').then(function(registration) {
                // Registration was successful
                console.log('service worker 注册成功, scope:', registration,registration.scope);
            }).catch(function(err) {
                // registration failed :(
                console.log('service worker 注册失败，failed: ', err);
            });
        });

        
    }
    // if ('serviceWorker' in navigator) {
    //     navigator.serviceWorker.ready.then(registration => {
    //         registration.unregister()
    //             .then(successful => {
    //                 if (successful) {
    //                     console.log('Service Worker 已成功取消注册');
    //                 } else {
    //                     console.log('Service Worker 取消注册失败');
    //                 }
    //             })
    //         .catch(error => {
    //         console.error('取消注册 Service Worker 时发生错误:', error);
    //         });
    //     });
    // }

</script>

</html>